﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using ApprovalFlow.Models;

namespace ApprovalFlow.Interface
{
    public interface ISubscriptionRepository
    {
        /// <summary>
        /// 创建订阅事件
        /// </summary>
        /// <param name="subscription"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task<string> CreateEventSubscription(EventSubscription subscription, CancellationToken cancellationToken = default);

        /// <summary>
        /// 获取订阅事件
        /// </summary>
        /// <param name="subscriptionId"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task<EventSubscription> GetSubscription(string subscriptionId, CancellationToken cancellationToken = default);

        /// <summary>
        /// 清除订阅事件
        /// </summary>
        /// <param name="subscriptionId"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task ClearSubscription(string subscriptionId, CancellationToken cancellationToken = default);

        /// <summary>
        /// 获取审批实例对应的订阅事件
        /// </summary>
        /// <param name="instance_id"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task<IEnumerable<EventSubscription>> GetSubscriptions(string instance_id, CancellationToken cancellationToken = default);

        Task<EventSubscription> GetFirstOpenSubscription(string eventName, string eventKey, CancellationToken cancellationToken = default);
    }
}
